import list from "./listTemplate.vue";
let hours = new Date().getHours();
export default {
  data() {
    return {
      page: 0,
      loading: false,
      listData: [],
      noMore: false,
      isLoadMore: false,
      flag:false,
      active_status:0,
      active_current:0,
      type:""
    }
  },
  activated(){
    this.initdata();
  },
  methods: {
    initdata() {
      this.page = 0;
      this.listData = [];
      this.loading = false;
      this.noMore = false;
      this.isLoadMore = false;
      this.status_list = [];
    },
    activeInfo({data,active_status,active_current,type}){
      this.type = type;
      this.active_status = active_status;
      this.active_current = active_current
      this.love_name = data.love_name || '爱心值';
      this.point_name = data.point_name || '积分';
      this.integral_name = data.integral_name || '消费积分'
      if(type == 'home'){
        this.status_list= data.stage_slot || [];
      }
      this.page = data.stage_list.current_page
      this.listData = data.stage_list.data || [];
    },
    getMoreActivity(){
      if(this.noMore) return false;
      this.loading = true;
      let json = this.getJson();
      let url = '';
      if(this.type == 'home'){
        url = "plugin.subscription.frontend.modules.activity.controllers.detail.index"
      }else{
        url = "plugin.subscription.frontend.modules.member.controllers.stage.index"
      }
      $http.post(url,json).then(({result,msg,data})=>{
        this.loading = false;
        if(result){
          this.page = json.page;
          this.setMore(this.page == data.stage_list.last_page);
          this.listData = this.listData.concat(data.stage_list.data);
        }else{
          this.$toast(msg);
        }
      })
    },
    getMoreData(){
      this.getMoreActivity()
    },
    getJson(){
      return{
        page:this.page + 1
      }
    },
    setMore(bool) {
      this.noMore = bool;
      this.isLoadMore = !bool;
    },
    goto(name, params = {}, query = {}) {
      this.$router.push(this.fun.getUrl(name, params, query));
    },
  },
  components: {
    list,
    overlay:()=>import("./overlay.vue")
  }
}